import sys
from pygame import KEYDOWN, K_KP_ENTER, QUIT
import time
def show_text(pygame,surface_handle, pos, text, color, font_bold=False, font_size=30, font_italic=False):
    """
    Function:文字处理函数
    Input：surface_handle：surface句柄
           pos：文字显示位置
           color:文字颜色
           font_bold:是否加粗
           font_size:字体大小
           font_italic:是否斜体
    """
    # 获取系统字体，并设置文字大小
    cur_font = pygame.font.SysFont("arial", font_size)

    # 设置是否加粗属性
    cur_font.set_bold(font_bold)

    # 设置是否斜体属性
    cur_font.set_italic(font_italic)

    # 设置文字内容
    text_fmt = cur_font.render(text, 1, color)

    # 绘制文字
    surface_handle.blit(text_fmt, pos)
def loading(pygame):
    screen = pygame.display.set_mode((1203, 600))
    init_background = pygame.image.load(
        "../resources/images/wel-come.png").convert_alpha()
    pygame.display.set_caption('AngryBirds')
    temp = 0
    flag = 0

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()

        screen.blit(init_background, (0, 0))
        text = u"Loading" + temp * u"."
        show_text(pygame,screen, (1000, 550), text, (255, 255, 255), True)
        temp += 1
        if temp == 4:
            temp = 0
            flag += 1
            if flag == 4:
                time.sleep(2)
                return

        time.sleep(0.5)
        pygame.display.update()